package hieudd.appgame.andengine;

import org.anddev.andengine.ui.activity.BaseGameActivity;

import android.view.Menu;
import android.view.MenuItem;

public abstract class BaseExample extends BaseGameActivity {



    private static final int MENU_TRACE = Menu.FIRST;



    @Override
    public boolean onCreateOptionsMenu(final Menu pMenu) {
            pMenu.add(Menu.NONE, MENU_TRACE, Menu.NONE, "Start Method Tracing");
            return super.onCreateOptionsMenu(pMenu);
    }

    @Override
    public boolean onPrepareOptionsMenu(final Menu pMenu) {
            pMenu.findItem(MENU_TRACE).setTitle(this.mEngine.isMethodTracing() ? "Stop Method Tracing" : "Start Method Tracing");
            return super.onPrepareOptionsMenu(pMenu);
    }

    @Override
    public boolean onMenuItemSelected(final int pFeatureId, final MenuItem pItem) {
            switch(pItem.getItemId()) {
                    case MENU_TRACE:
                            if(this.mEngine.isMethodTracing()) {
                                    this.mEngine.stopMethodTracing();
                            } else {
                                    this.mEngine.startMethodTracing("AndEngine_" + System.currentTimeMillis() + ".trace");
                            }
                            return true;
                    default:
                            return super.onMenuItemSelected(pFeatureId, pItem);
            }
    }


}
